import * as Blockly from 'blockly/core';
export namespace Tanslate {
    export function tr(data: any) {
        let str = JSON.stringify(data)
        const matchs = str.matchAll(/%\{[\w\_]+\}/g)
        let match = matchs.next()
        while (match.value) {

            const key = match.value[0].slice(2, -1)
            const val = Blockly.Msg[key]
            if (val) {
                str = str.replace(match.value[0], val)
            }
            match = matchs.next()
        }

        return JSON.parse(str)
    }
}